<?php
set_time_limit(0);
error_reporting(E_ALL);
// SELECT a.* FROM `u3` a, u3 b WHERE a.id != b.id  and a.name=b.name;

include 'config.php';

$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
 
$sql='SELECT a.fen as afen,a.id as aid, a.name as aname, a.phone as aphone, b.* FROM `u3` a, u3 b WHERE a.id != b.id and a.phone=b.phone and a.name=b.name limit 0, 100';

$query =$mysqli->query($sql);
while ($list=$query->fetch_array()){
	if ($list['afen'] < $list['fen']){
		$myId=$list['aid'];
	}else{
		$myId=$list['id'];
	}
	echo $myId;
	if (!empty($list['aid']) && !empty($list['id'])){
		echo "<br />";
		echo $list['aid'];
		echo "<br />";
		echo $list['id'];
		
		$mysqli->query("delete from u3 where id='".$myId."' ");
	}
	echo "<br />";
	
	echo $list['phone'];
	echo "<br />";
	echo "<br />";
	//var_dump($list);
	
	
}
 